Package-level declarations

Types

Link copied to clipboard
interface I18nable

允许对象通过 i18n 获取 I18nService

Link copied to clipboard
object IO

用于告知 scope 使用 IO 线程池 Dispatchers.IO。(使用 scope(IO)

Link copied to clipboard
interface JsonStorable

允许对象通过 store 获取 JsonStore

Link copied to clipboard
interface Loggable

允许对象通过 log 获取 Logger,AutoTweaker 使用 logback 作为实现,插件仅需依赖 slf4j。

Link copied to clipboard
interface ObjectStorable

允许对象通过 objects 获取 ObjectStorage

Link copied to clipboard
class ServiceRegistry(val trace: (KClass<*>) -> TraceRecorder, val store: (KClass<*>) -> JsonStore, lazyObjects: () -> ObjectStorage, lazySetting: () -> SettingService, lazyI18n: () -> I18nService)

请不要构造此类或访问此类的伴生对象。

Link copied to clipboard
interface Settable

允许对象通过 setting 获取 SettingService

Link copied to clipboard
interface Traceable

允许对象通过 trace 获取 TraceRecorder

Properties

Link copied to clipboard
const val APP_NAME: String

值为 AutoTweaker

Link copied to clipboard

值为 autotweaker

Link copied to clipboard

存储配置及其他数据的目录,请使用提供的持久化 API 而不是直接在此路径下存放文件。

Link copied to clipboard

获取 AutoTweaker 提供的 I18nService

Link copied to clipboard

四个空格字符(" ")。

Link copied to clipboard

长度为 10 的 -,也就是 ----------

Link copied to clipboard
val Loggable.log: Logger

获取 Logger,请遵循日志规范,不要污染程序日志。

Link copied to clipboard
const val MASK_CHAR: Char = '*'

星号,也就是 *

Link copied to clipboard

获取 AutoTweaker 提供的 ObjectStorage

Link copied to clipboard

用于加载插件 jar 的目录,此目录中只有以 .jar 结尾的文件会被加载,jar 或 class 损坏的文件不会被加载。

Link copied to clipboard

获取 AutoTweaker 提供的 SettingService

Link copied to clipboard
const val SPACE: Char = ' '

一个空格字符(' ')。

Link copied to clipboard

获取 AutoTweaker 提供的 JsonStore。 同一类获取到的 JsonStore 始终相同,不同类获取到的 JsonStore 相互隔离。

Link copied to clipboard

存放临时文件的目录,通常为 /tmp/autotweaker

Link copied to clipboard

获取 AutoTweaker 提供的 TraceRecorder,自身作为 origin

Functions

Link copied to clipboard

打印一条用于临时调试的 error 级别日志,特殊的命名便于通过自动化脚本扫描。

Link copied to clipboard
fun allNull(vararg items: Any?): Boolean

items 全部为 null 返回 true。

Link copied to clipboard
inline fun <T> T.andLog(logger: Logger, crossinline log: Logger.(T) -> Unit): T

用于在链式调用中插入日志,示例:

Link copied to clipboard
fun <T> T.discard()

丢弃对象并返回 Unit

fun <T, R> T.discard(result: R?): R?

丢弃对象并返回 result

Link copied to clipboard
inline fun <T> Iterable<T>.forEachBetween(action: (T) -> Unit, between: () -> Unit)

遍历一个 Iterable 对象并调用 action,在每两次遍历中间调用 between

Link copied to clipboard
inline suspend fun <T> Array<T>.forEachParallel(crossinline action: suspend (T) -> Unit)
inline suspend fun <T> Iterable<T>.forEachParallel(crossinline action: suspend (T) -> Unit)
inline suspend fun <K, V> Map<K, V>.forEachParallel(crossinline action: suspend (Map.Entry<K, V>) -> Unit)

forEach 并行版,会为每个条目启动一个协程来执行 action

inline suspend fun <T> Array<T>.forEachParallel(limit: Int, crossinline action: suspend (T) -> Unit)
inline suspend fun <T> Iterable<T>.forEachParallel(limit: Int, crossinline action: suspend (T) -> Unit)
inline suspend fun <K, V> Map<K, V>.forEachParallel(limit: Int, crossinline action: suspend (Map.Entry<K, V>) -> Unit)

forEach 并行版,会为每个条目启动一个协程来执行 action,同时限制并发数为 limit

Link copied to clipboard

请不要调用此方法。

Link copied to clipboard
fun line(length: Int): String

输出 length- 组成的字符串。

Link copied to clipboard

如果 this 为 null,返回 Clock.System.now,否则返回 this 本身。

Link copied to clipboard
fun <C : CharSequence> C.orNull(): C?

如果 CharSequence 为空,返回 null,否则返回 CharSequence 本身。

fun <T, C : Collection<T>> C.orNull(): C?

如果 Collection 为空,返回 null,否则返回 Collection 本身。

fun <T> Array<T>.orNull(): Array<T>?

如果 Array 为空,返回 null,否则返回 Array 本身。

fun <K, V> Map<K, V>.orNull(): Map<K, V>?

如果 Map 为空,返回 null,否则返回 Map 本身。

Link copied to clipboard
fun Loggable.scope(io: IO? = null): CoroutineScope

快速创建一个协程作用域,并在崩溃时记录日志。

Link copied to clipboard
operator fun Char.times(n: Int): String

Char 添加 * 操作符的支持,例如 '-' * 10 输出 10 个 -

operator fun String.times(n: Int): String

String 添加 * 操作符的支持,例如 "**" * 10,输出 20 个 *

Link copied to clipboard
fun String.toMasked(minLength: Int = 15, prefixKeep: Int = 5, suffixKeep: Int = 4): String

给敏感信息例如 api key 打码。